<?php

namespace App\Admin\Controllers\Api;

use App\Models\VehicleSeries;
use App\Models\Activity;
use App\Models\ActivityPrize;
use App\Models\BannerSign;
use App\Models\Banner;
use App\Models\Dealer;

class SelectController
{
    public function activities(){
        $data = Activity::select('id','title as text')->get();
        return $data;
    }

    public function series(){
        $data = VehicleSeries::select('id','series_name as text')->get();
        return $data;
    }

    public function bannerSigns(){
        $data = BannerSign::select('sign','description as text')->get()->toArray();
        foreach($data as &$arr){
            $arr['id'] = $arr['sign'];
            unset($arr['sign']);
        }
        return $data;
    }

    public function linkTypes(){
        $types = Banner::$linkTypeMap;
        $data = [];
        foreach($types as $k=>$v){
            $data[] = [
                'id' => $k,
                'text' => $v
            ];
        }
        return $data;
    }

    public function dealerLevels(){
        $levels = Dealer::$levelMap;
        $data = [];
        foreach($levels as $k=>$v){
            $data[] = [
                'id' => $k,
                'text' => $v
            ];
        }
        return $data;
    }

    public function prizeLevels(){
        $levels = ActivityPrize::$levelMap;
        $data = [];
        foreach($levels as $k=>$v){
            $data[] = [
                'id' => $k,
                'text' => $v
            ];
        }
        return $data;
    }

    public function prizeTypes(){
        $rows = ActivityPrize::$typeMap;
        $data = [];
        foreach($rows as $k=>$v){
            $data[] = [
                'id' => $k,
                'text' => $v
            ];
        }
        return $data;
    }

    public function prizeLimits(){
        $rows = ActivityPrize::$limitMap;
        $data = [];
        foreach($rows as $k=>$v){
            $data[] = [
                'id' => $k,
                'text' => $v
            ];
        }
        return $data;
    }
}
